package com.wd.tech.app;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.EditText;

/**
 * @author ：created by
 * Create Date ：2020/7/10 17
 * Package_Name : ZYM
 * Describe :
 */
@SuppressLint("AppCompatCustomView")
public class MyEditView extends EditText {

    private Paint paint;
    private float x;
    private float y;
    private String nowLength = "0/300";
    public MyEditView(Context context, AttributeSet attrs) {
        super(context, attrs);
        initPaint();
    }

    public String getNowLength() {
        return nowLength;
    }

    public void setNowLength(String nowLength) {
        this.nowLength = nowLength;
    }

    private void initPaint() {
        paint = new Paint();
        paint.setAntiAlias(true);
        paint.setStyle(Paint.Style.FILL_AND_STROKE);
        paint.setColor(Color.BLACK);
        paint.setTextSize(25);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        x = getWidth()-100;
        y = getHeight()-60;
        Log.i("###", "onDraw: "+x+"----"+y);
        canvas.drawText(nowLength,x,y,paint);
    }
}
